package com.ruoyi.web.controller.laiqianba.product;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.ProductProfitUvInfo;
import com.ruoyi.product.service.IProductProfitUvInfoService;
import com.ruoyi.web.wrapper.ProductProfitUvInfoWrapper;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产品收益uv统计信息Controller
 * 
 * @author ruoyi
 * @date 2023-09-04
 */
@RestController
@RequestMapping("/product/profitUvInfo")
public class ProductProfitUvInfoController extends BaseController
{
    @Autowired
    private IProductProfitUvInfoService productProfitUvInfoService;

    /**
     * 查询产品收益uv统计信息列表
     */
    @PreAuthorize("@ss.hasPermi('product:profitUvInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProductProfitUvInfo productProfitUvInfo)
    {
        startPage();
        List<Map<String, Object>> list = productProfitUvInfoService.selectProductProfitUvInfoMapList(productProfitUvInfo);
        list = new ProductProfitUvInfoWrapper(list).wrap();
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('product:profitUvInfo:count')")
    @GetMapping("count/list")
    public TableDataInfo count(ProductProfitUvInfo productProfitUvInfo)
    {
        List<Map<String, Object>> list = productProfitUvInfoService.selectProductCount(productProfitUvInfo);
        list = new ProductProfitUvInfoWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出产品收益uv统计信息列表
     */
    @PreAuthorize("@ss.hasPermi('product:profitUvInfo:export')")
    @Log(title = "产品收益uv统计信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProductProfitUvInfo productProfitUvInfo)
    {
        List<ProductProfitUvInfo> list = productProfitUvInfoService.selectProductProfitUvInfoList(productProfitUvInfo);
        ExcelUtil<ProductProfitUvInfo> util = new ExcelUtil<ProductProfitUvInfo>(ProductProfitUvInfo.class);
        util.exportExcel(response, list, "产品收益uv统计信息数据");
    }

    /**
     * 获取产品收益uv统计信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('product:profitUvInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(productProfitUvInfoService.selectProductProfitUvInfoById(id));
    }

    /**
     * 新增产品收益uv统计信息
     */
    @PreAuthorize("@ss.hasPermi('product:profitUvInfo:add')")
    @Log(title = "产品收益uv统计信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProductProfitUvInfo productProfitUvInfo)
    {
        return toAjax(productProfitUvInfoService.insertProductProfitUvInfo(productProfitUvInfo));
    }

    /**
     * 修改产品收益uv统计信息
     */
    @PreAuthorize("@ss.hasPermi('product:profitUvInfo:edit')")
    @Log(title = "产品收益uv统计信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProductProfitUvInfo productProfitUvInfo)
    {
        return toAjax(productProfitUvInfoService.updateProductProfitUvInfo(productProfitUvInfo));
    }

    /**
     * 删除产品收益uv统计信息
     */
    @PreAuthorize("@ss.hasPermi('product:profitUvInfo:remove')")
    @Log(title = "产品收益uv统计信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(productProfitUvInfoService.deleteProductProfitUvInfoByIds(ids));
    }

    @GetMapping(value = "/getChannelCodeByProductId")
    public TableDataInfo getChannelCodeByProductId(ProductProfitUvInfo productProfitUvInfo)
    {
        List<Map<String, Object>> list = productProfitUvInfoService.getChannelCodeByProductId(productProfitUvInfo);
        return getDataTable(list);
    }
}
